package com.itheima.dao;


import com.github.pagehelper.Page;
import com.itheima.pojo.Menu;
import org.apache.ibatis.annotations.Select;
import java.util.List;

/**
 * @author shi
 * @version v1.0
 * @date 2019/8/7 21:41
 * @description TODO
 **/
public interface MenuDao {
    @Select("select * from t_menu")
    Page<Menu> findPage(String queryString);

    @Select("select * from t_menu where level = 1")
    List<Menu> findParentMenu();

    @Select("select * from t_menu where parentMenuId = #{parentMenuId}")
    List<Menu> findChildrenMenuByid(Integer parentMenuId);

    void addMenu(Menu menu);

    void edit(Menu menu);

    /**
     * 根据用户名，获取该用户所能使用的菜单列表
     * @param username
     * @return
     */
    List<Menu> getMenuListByUsername(String username);

    @Select("select * from t_menu where id = #{id}")
    Menu findMenuByID(Integer id);

    @Select("delete from t_menu where id = #{id}")
    void deleteMenuByID(Integer id);

    @Select("select * from t_menu")
    List<Menu> findAll();
    @Select("select count(menu_id) from t_role_menu  where menu_id = #{id}")
    Long findCountByRoleId(Integer id);
}
